package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.2.4  业务产品标识
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_2_4_BusiProdFlagEnum {
    _0("0", "一般交易中，取缺省值0"),
    _A("A", "用于转账交易，代表助农转账汇款用于消费交易，代表助农缴费"),
    _B("B", "用于转账交易，代表助农现金汇款"),
    ;

    private String code;
    private String desc;

    F60_2_4_BusiProdFlagEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_2_4_BusiProdFlagEnum find(String code) {
        F60_2_4_BusiProdFlagEnum result = Arrays.stream(F60_2_4_BusiProdFlagEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
